import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
   title: '分类',
   align:"center",
   dataIndex: 'classify_dictText'
  },
   {
    title: '科目名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '价格',
    align:"center",
    dataIndex: 'cost'
   },
   {
    title: '报名年级',
    align:"center",
    dataIndex: 'gradeDepts'
   },
   {
    title: '报名人数',
    align:"center",
    dataIndex: 'studentCount'
   },
   {
    title: '上课时间',
    align:"center",
    dataIndex: 'classTime'
   },
   {
    title: '上课地点',
    align:"center",
    dataIndex: 'classAddress'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "分类",
      field: 'classify',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"cs_course_clazz where status=1,name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "科目名称",
      field: 'name',
      component: 'JInput',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '科目名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入科目名称!'},
          ];
     },
  },
  {
    label: '分类',
    field: 'classify',
    component: 'JDictSelectTag',
    required:true,
    componentProps:{
            stringToNumber:true,
            dictCode:"cs_course_clazz where status=1,name,id"
    },
  },
  {
    label: '价格',
    field: 'cost',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入价格!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '报名年级',
    field: 'gradeDeptIds',
    component: 'JSelectDept',
    componentProps:{
      // checkStrictly:true,
      field:'deptId',
      multiple:true,
      params:{
        businessCode:1002
      }
    }
  },
  {
    label: '上课时间',
    field: 'classTime',
    component: 'RangeTime',
    componentProps: {
      //日期格式化
      format:'HH:mm:ss',
      //范围文本描述用集合
    },
  },
  {
    label: '上课地点',
    field: 'classAddress',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}